<?php

class Date 
{
	
	function week($timestamp) 
	{
		$date_info = getdate($timestamp);
		$timestamp = strtotime($date_info[year].'-'.$date_info[mon].'-'.$date_info[mday]);
		$sunday = $timestamp - $date_info['wday']*24*3600;

		for($i=0; $i<=6; $i++)
		{
			$time = $sunday + $i*24*3600;
			$week[$i] = getdate($time);
		}

		return $week;
	}

	function month($timestamp)
	{
		$date = date('Y-m', $timestamp);
		$month_start = strtotime($date.'-1') ;
		$date_info = getdate($month_start);

		for($i=1; $i<=31; $i++) 
		{
			if(checkdate($date_info[mon], $i , $date_info[year])) 
			{
				$time = strtotime($date_info[year].'-'.$date_info[mon].'-'.$i);
				$month[$i] = getdate($time);
			}
		}

		return $month;
	}

	function InToday($time)
	{
		$current_date = date('Y-m-d', time());
		$date = date('Y-m-d', $time);

		if($current_date == $date)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	function InWeek($time)
	{
		$current_dateInfo = getdate(time());
		$timestamp = strtotime($current_dateInfo[year].'-'.$current_dateInfo[mon].'-'.$current_dateInfo[mday]);
		$current_sunday = $timestamp - $current_dateInfo['wday']*24*3600;
		$date_info = getdate($time);
		$timestamp = strtotime($date_info[year].'-'.$date_info[mon].'-'.$date_info[mday]);
		$sunday = $timestamp - $date_info['wday']*24*3600;

		if( $current_sunday == $sunday )
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	function InMonth($time)
	{
		$current_month = date('Y-m',  time());
		$month = date('Y-m',  $time);

		if( $current_month == $month )
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	function InYear($time)
	{
		
		$cyear = date( 'Y', time() );
		$lyear = date( 'Y', $time );
		return $cyear == $lyear;
		
	}
}

?>